package edu.gatech.PI2Hbase;
	
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.util.Bytes;

public class TestMR {



	    public static void main(String[] args) throws Exception {

	        HBaseConfiguration conf = new HBaseConfiguration();
	        conf.set("hbase.master", "localhost");
	        conf.set("hbase.zookeeper.quorum", "localhost:2181");
	        
	        HTable htable = new HTable(conf, "PiReduce");

	        Scan scan = new Scan();
	        ResultScanner scanner = htable.getScanner(scan);
	        Result r;
	        while (((r = scanner.next()) != null)) {
	            byte[] key = r.getRow();
	            String userId = String.valueOf(key);
	            byte[] totalValue = r.getValue(Bytes.toBytes("Info"), Bytes.toBytes("Value"));
//	            int count =Integer.parseInt(Bytes.toString(totalValue));
	            double count =Bytes.toDouble(totalValue);
	            System.out.println("tagname: " + userId+ ",  value: " + count+ r.list().get(0).getTimestamp());
	        }
	        scanner.close();
	        htable.close();
	    }

}
